package com.hua.yuan.common.https;

import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;
import com.zhy.http.okhttp.request.RequestCall;

import java.util.Map;

/**
 * Created by huangyang on 2018/4/22.
 * 获取数据的请求
 */

public class GetDataTask {

    /**
     * 请求数据 post请求
     *
     * @param url            地址
     * @param params         参数
     * @param stringCallback 回调
     */
    public static void getDataPost(String url, Map<String, String> params, StringCallback stringCallback) {

        RequestCall call = OkHttpUtils.post()
                .url(url)
                .params(params)
                .build();
        if (stringCallback != null) {
            if (call != null) {
                call.execute(stringCallback);
            }
        }

    }

    /**
     * 请求数据 get请求
     *
     * @param url            地址
     * @param params         参数
     * @param stringCallback 回调
     */
    public static void getDataGet(String url, Map<String, String> params, StringCallback stringCallback) {

        RequestCall call = OkHttpUtils.get()
                .url(url)
                .params(params)
                .build();
        if (stringCallback != null) {
            if (call != null) {
                call.execute(stringCallback);
            }
        }

    }


}
